<?php
require_once("../../resources/commons.php");
require_once("../../data/Item.php");
require_once("dashboard_commons.php");

SessionManager::getInstance()->checkSession();

//A simple script which displays the action associated with the specified Id
if(isset($_REQUEST["id"])){
	$l_action=Item::getFromPrimaryKey(base64_decode($_REQUEST["id"]));

	if(isset($l_action)){
		//Display action only if the user has created the action or has been allocated it.
		$l_me=SessionManager::getCurrentLoggedUserId();
		if($l_action->isAccessAllowed($l_me)){
			displayTop("Action: " . $_REQUEST["id"],null,null);
			displayAction($l_action);
		}else{
			displayError("Forbidden, not sufficient rights");
		}
	}else{
		echo "<b>Unknown action</b>";
	}
?>
<center><br/><a href="javascript:history.back();"><img border="0" src="<?=ROOT_PATH ?>/apps/resources/images/close.png"/></a></center>
<?php	
	displayBottom();
}else{
	//Redirect to home if invalid parameter is provided
	HTTP::redirect(ROOT_PATH . "/apps/");
}
?>